<?php

namespace App\Models;

use App\User;
use Illuminate\Database\Eloquent\Model;



#项目选择表模型
class Selection extends Model
{

    #主键
    public $primaryKey='sid';

	/**
	 * 表明模型是否应该被打上时间戳
	 *
	 * @var bool
	 */
	public $timestamps = false;



    #每个学生只能有一个选择，一对一
    public function student(){
        return $this->hasOne('App\User','uid','sid');
    }




    #存储一条新纪录
    public static function store($request){

    	$selection = new Selection;
    	$selection->pid=$request->input('pid');
    	$selection->sid=$request->input('sid');
        
    	$selection->qualified=0;
    	try {
    		$selection->save();

    	} catch (Exception $e) {
    		return false;
    	}
    	
    	return true;
    }




}
